<?php

class Application_Model_DbTable_Account extends Zend_Db_Table_Abstract {

    protected $_name = 'account';
	
	public function getAccount($id){
        $row = $this->fetchRow("id=".$id);
        return $row;
	}
	
	public function getAccountByUserId($userId){
		$row = $this->fetchRow("userId=".$userId);
		return $row;
	}
	
	public function getAccountList(){
		$row = $this->fetchAll();
		return $row;
	}	
		
	public function createAccount($userId, $accountNumber, $accountName){
		$row = $this->createRow();
		$row->userId = $userId;
		$row->accountNumber = $accountNumber;
		$row->accountName = $accountName;		
		$row->save();
		return $row;
	}
	
	public function updateAccount($id, $balance,$points){		
		$row = $this->getAccount($id);
		if(count($row) > 0) {
			$row->balance = $balance;
			$row->points = $points;		
			$row->save();
		}
		return $row;
	}	
}
